package com.smartstate.IOC.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.smartstate.IOC.entity.Alarm;
import com.smartstate.IOC.vo.AlarmVo;
import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;

@Mapper
public interface AlarmMapper extends BaseMapper<Alarm> {

    @Select("select  *  from   alarm  where abnormaltime < #{nowDate} and abnormaltime >#{lastDate}")
    List<Alarm> getLastTime(Date nowDate, Date lastDate);

    @Select("<script> select  count(1)  from   alarm  where 1=1 \n" +
            "<if test=\"stateType!=null and stateType!='' \">\n" +
            "   AND state = #{stateType}\n" +
            "</if> </script>")
    Integer getAlarmCountByType(@Param("stateType") String stateType);


    @Select("SELECT * FROM alarm  where state != 1 ORDER BY abnormaltime desc")
    List<Alarm> queryPageByCondition();

    @Select("select count(*) from alarm  where  types = '1'")
    Integer selectAlarmEvent();

    @Select("select count(*) from alarm  where  types = '18'")
    Integer selectAlarmVideo();

    @Select("select count(*) from alarm  where  types = '6,7,8,9,10,11,12,13,14,15,16,17'")
    Integer selectAlarmIndustry();

    @Select("select count(*) from alarm  where  types = '2'")
    Integer selectAlarmMeter();
    @Select("select count(attributes) from  alarm where attributes = #{string}")
    Integer selectEventTotal(String string);

    @Select("select * from alarm where  STR_TO_DATE(abnormaltime,'%Y-%m-%d %T') >= '${s}' and  STR_TO_DATE(abnormaltime,'%Y-%m-%d %T')<= '${s1}' ")
    List<Alarm> getThreeAlarm(String s, String s1);

    @Select("select count(attributes) from alarm where attributes = '静压'")
    Integer getStaticPressure();

    @Select("select count(attributes) from alarm where attributes = '湿度'")
    Integer getHumidity();

    @Select("select count(attributes) from alarm where attributes = '温度'")
    Integer getTemperature();

    @Select("select count(attributes) from alarm where attributes = '露点'")
    Integer getDewPoint();

    @Select("select count(attributes) from alarm where attributes = '尘埃粒子0.5'")
    Integer getLittleParticle();

    @Select("select count(attributes) from alarm where attributes = '尘埃粒子5.0'")
    Integer getLongParticle();


    @Select("SELECT * FROM alarm  ")
    List<Alarm> getEquimentAlarm();
}
